import { networkInterfaces } from 'os';
/**获取mac地址信息 */
export const getMacAddress = function (): string {
  const interfaces = networkInterfaces();
  let macAddress = '';
  for (const interfaceName of Object.keys(interfaces)) {
    const interfaceInfos = interfaces[interfaceName];

    if (interfaceInfos) {
      for (const interfaceInfo of interfaceInfos) {
        if (interfaceInfo.mac && interfaceInfo.mac !== '00:00:00:00:00:00') {
          macAddress = interfaceInfo.mac;
          break;
        }
      }
    }

    if (macAddress.length > 0) break;
  }

  return macAddress;
};
